void confirm_buy_ticket_btn_event_cb(lv_event_t * e)
{
    char selected_text[128];
    lv_dropdown_get_selected_str(movies_dropdown, selected_text, sizeof(selected_text));
    FILE *fp = fopen(user_path, "r+");
    rewind(fp);
    char buffer[1024];
    bool movie_found = false;
    long insert_pos = 0;  // 新记录插入位置

    //查看是否已购买
    while (fgets(buffer, sizeof(buffer), fp)) 
    {
        char current_movie[128];
        int quantity = 0;
        
        if (sscanf(buffer, "电影名:%127[^,],数量:%d", current_movie, &quantity) == 2) 
        {
            if (strcmp(current_movie, selected_text) == 0) 
            {
                // 找到目标电影，更新数量
                quantity++;
                fseek(fp, -strlen(buffer), SEEK_CUR); // 回退到行首
                fprintf(fp, "电影名:%s,数量:%d\n", selected_text, quantity);
                movie_found = true;
                break;
            } 
        }
        insert_pos = ftell(fp); // 记录最后一行位置   
    }
    //如果没找到
    if (!movie_found) 
    {
        fseek(fp, insert_pos, SEEK_SET); // 移动到文件末尾
        fprintf(fp, "电影名:%s,数量:1\n", selected_text);
    }
    fclose(fp);
    lv_obj_t *success_popup = lv_msgbox_create(ticket, "购票成功", "您已成功购买电影票！", NULL, true);
    lv_obj_set_style_text_font(success_popup, &lv_font_source_han_sans_bold_20, 0);
    lv_obj_align(success_popup, LV_ALIGN_CENTER, 0, 0);
    lv_obj_add_event_cb(success_popup, NULL, LV_EVENT_ALL, NULL);
}